﻿// ------------------------------------------------------------------------------------------------
//  <copyright file="DialogUtil.cs" company="Iveely">
//    Copyright (c) Iveely Liu.  All rights reserved.
//  </copyright>
//  
//  <Create Time>
//    03/02/2013 21:59 
//  </Create Time>
//  
//  <contact owner>
//    liufanping@iveely.com 
//  </contact owner>
//  -----------------------------------------------------------------------------------------------

#region

using System.Windows.Forms;

#endregion

namespace IveelySE.Tools.Common
{
    /// <summary>
    ///   对话框操作
    /// </summary>
    public class DialogUtil
    {
        /// <summary>
        ///   打开文件对话框
        /// </summary>
        /// <param name="filter"> 过滤器 </param>
        /// <returns> 返回文件路径 </returns>
        public static string OpenFile(string filter)
        {
            var openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = filter;
            openFileDialog.Title = "Open Iveely File";
            openFileDialog.ValidateNames = true;
            openFileDialog.CheckFileExists = true;
            openFileDialog.CheckPathExists = true;
            if(openFileDialog.ShowDialog() == DialogResult.OK)
            {
                return openFileDialog.FileName;
            }
            return "";
        }
    }
}